package com.pubsys.main.client.util;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public abstract class Debug {
	private static VerticalPanel panel = new VerticalPanel();
	private static boolean init = false;
	public static boolean DEBUGGING = false;
	
	private static void verifyInitedPanel(){
		if (!init){
			clear();
			init = true;
		}
	}
	
	public static void setDebuggingMode(boolean debug){
		DEBUGGING = debug;
	}
	
	public static void clear(){
		RootPanel.get("_gwt_debugPanel").clear();
		panel.clear();		
		RootPanel.get("_gwt_debugPanel").add(panel);		
	}
	
	public static void writeMessage(String text){
		if(!DEBUGGING)
			return;
		
		verifyInitedPanel();
		panel.add(new Label(text));
	}
	
	
}
